


export default {
    set(key, value) {
        if (typeof value === "number") {
            value = value.toString();
        } else if (typeof value === "boolean") {
            value = value.toString();
        } else if (typeof value === "object") {
            value = JSON.stringify(value);
        }
        localStorage.setItem(key, value);
    },
    setItem(key, value) {
        this.set(key, value);
    },

    get(key) {
        const item = localStorage.getItem(key);
        if (item === "true") {
            return true;
        } else if (item === "false") {
            return false;
        }

        try {
            const v = parseFloat(item);
            if (!isNaN(v)) {
                return v;
            }
        } catch (_) {}
        try {
            return JSON.parse(item);
        } catch (_) {}
        return item;
    },
    getItem(key) {
        this.get(key);
    },

    remove(key) {
        localStorage.removeItem(key);
    },
    removeItem(key) {
        localStorage.removeItem(key);
    },

    clear() {
        localStorage.clear();
    }
}

